package org.thingsboard.server.dao.jpa.imp;

import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;
import org.thingsboard.server.dao.jpa.TArea;
import org.thingsboard.server.dao.jpa.dto.TAreaDto;
import org.thingsboard.server.dao.util.SqlDao;

import java.util.List;

@SqlDao
public interface AreaRepository extends CrudRepository<TArea,String> {

    @Query("SELECT new TArea(a.areaId,a.areaName) FROM TArea a LEFT JOIN TAppArea b ON a.areaId=b.areaId left join TApp c on b.appId=c.appId where c.appCode = :appCode")
    List<TArea> findTArea(@Param("appCode") String appCode);
}
